package com.woniuxy.mapper;


import com.woniuxy.entity.ShopOrders;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    int insert(ShopOrders order);

    @Update("UPDATE `shop_orders` SET status = #{status}, update_time = NOW() WHERE order_number = #{orderNumber}")
    int updateStatusByOrderNumber(@Param("orderNumber") String orderNumber,
                                  @Param("status") Integer status);

    @Select("SELECT * FROM `shop_orders` WHERE order_number = #{orderNumber}")
    ShopOrders selectByOrderNumber(String orderNumber);

    // 查询未支付的预约订单
    @Select("SELECT * FROM  shop_orders WHERE user_id = #{userId}  And status = #{status} and pay_type = #{pay_type}")
    @Results({
            @Result(column = "user_id", property = "userId"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "total_amount", property = "totalAmount"),
            @Result(column = "payment_type", property = "paymentType"),
            @Result(column = "payment_time", property = "paymentTime"),
            @Result(column = "pay_type", property = "payType"),
            @Result(column = "id_card", property = "idCard"),
            @Result(column = "order_number", property = "orderNumber"),
            @Result(column = "payment_amount", property = "paymentAmount"),
    })
    List<ShopOrders> selectByuserIdForUnpay(@Param("userId") Integer userId,@Param("status") Integer status,@Param("pay_type") Integer pay_type );
}
